exports.getErr=function(err="服务器报错",code=500){

    return{
        code,
        err
    }
}
exports.getResult=function(data){
    return{
        code:0,
        msg:'',
        data
    }
}

exports.asynchandler = (handler)=>{
    return async (req,res,next)=>{
        try {
         const result = await handler(req,res,next);
         res.send(exports.getResult(result));
            
        } catch (error) {
            next(error);
        }

    }
}